package com.cjb.fegin.web;

import com.cjb.fegin.rpc.UserRpc;
import com.cjb.fegin.vo.UserVo;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/feign")
public class UserController {


    @Resource
    private UserRpc userRpc;


    @RequestMapping("/saveUser")
    @ResponseBody
    public String saveUser(){
         try{
             UserVo userVo = new UserVo();
             userVo.setUsername("user_feign");
             userVo.setPassword("root");
             userVo.setSex("男");
             return userRpc.saveUser(userVo);
         }catch(Exception exception){
             return null;
         }
    }




    @GetMapping("users")
    public String listUsers(){
       return  userRpc.listUsers();
    }


}
